﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using System.Windows.Forms;
using DLL.Entities;


namespace DLL.Entities
{
    public class WriteXML
    {

        MISStatus MS_Obj = new MISStatus();
        Targets TAR_Obj = new Targets();
        Clear_Target clear = new Clear_Target();


   
        public void WriteMISStatus(string status, int missileCount, string type, string dir)
        {
            MS_Obj.CurrentStatus = status;
            MS_Obj.MissileCount = missileCount;
            MS_Obj.MissileType = type;


            XmlSerializer serializer = new XmlSerializer(typeof(MISStatus));
            TextWriter textWriter = new StreamWriter(dir);
            serializer.Serialize(textWriter, MS_Obj);               
            textWriter.Close();          
        }


        public void WriteRadUpdate(string speed, string size, string altitude, string direction, string distance, string name)
        {
            TAR_Obj.Altitude = altitude;
            TAR_Obj.Speed = speed;
            TAR_Obj.Size = size;
            TAR_Obj.Direction = direction;
            TAR_Obj.Distance = distance;
            TAR_Obj.TargetName = name;

            XmlSerializer serializer = new XmlSerializer(typeof(Targets));
            TextWriter textWriter = new StreamWriter("../../../DLL/XML/RAD_Update.xml");
            serializer.Serialize(textWriter, TAR_Obj);
            textWriter.Close();
        }

        public void ClearTarget(int timer)
        {
            clear.Timer = timer;

            XmlSerializer serializer = new XmlSerializer(typeof(Clear_Target));
            TextWriter textWriter = new StreamWriter("../../../DLL/XML/Target_Clear.xml");
            serializer.Serialize(textWriter, clear);
            textWriter.Close();
        }

    }
}
